package com.hammera.common.baseUI

import android.os.Bundle
import com.zzh.base.BaseActivity
import com.zzh.base.BaseModel
import com.zzh.base.utils.TUtils

/**
 * Created by din on 2018/8/7.
 * <p>
 * Email: godcok@163.com
 *
 */
abstract class BaseMVPActivity<M : BaseModel<*>, V : BaseView, P : BasePresenter<M, V>> :
        BaseActivity(), BaseView {
    protected var mPresenter: P? = null
    protected var mModel: M? = null
    protected var mView: V? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        mModel = TUtils.getT(this, 0)
        mView = this as V
        mPresenter = TUtils.getT(this, 2)
        mPresenter?.setMV(mModel, mView)
        mPresenter?.setContext(applicationContext)
        super.onCreate(savedInstanceState)
    }

    override fun onDestroy() {
        super.onDestroy()
        mPresenter?.onDestroy()
    }

}